package edu.sctu.zhuyingzhi.month201505.day20150503.exception_1.Method;

import javax.swing.*;

/**
 * Created by user13 on 2015/5/3.
 */
public class JudgeArray {
    public void array(){
      int in,i;
        String input;
        int array[];
        do   {
            input= JOptionPane.showInputDialog("请输入数组长度：");
            in=Integer.parseUnsignedInt(input);

            try {
                array=new int[in];
                for (i=0;i<5;i++){
                    System.out.println("输出："+array[i]+"   i="+i);

                }
            }
            catch (NumberFormatException e){
                  JOptionPane.showConfirmDialog(null,"数组长度为负数 不符合要求");

            }
            catch (ArrayIndexOutOfBoundsException f){
                JOptionPane.showConfirmDialog(null,"数组长度 不符合要求");
            }
        }while(in<5);
    }


    public static void main(String[] args) {
        new JudgeArray().array();

}
}
